package com.zhiling.www.controller;

import com.zhiling.www.entity.Result;
import com.zhiling.www.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/warehouse")
public class WarehouseController {

    @Autowired
    private WarehouseService warehouseService;

    //查询当前用户持仓信息
    @RequestMapping("/list")
    public Result list(HttpServletRequest request){
        String token = request.getHeader("token");
        return warehouseService.list(token);
    }

    //查询当前用户单个股票持仓信息
    @RequestMapping("/loadstock")
    public Result loadStock(String codeOrName,HttpServletRequest request){
        String token = request.getHeader("token");
        return warehouseService.loadStock(codeOrName,token);
    }

    //加载每一种股票的可卖数量
    @RequestMapping("/loadsellnum")
    public Result loadSellNum(String stockcode,HttpServletRequest request){
        String token = request.getHeader("token");
        return warehouseService.loadSellNum(stockcode,token);
    }
}
